#ifndef UDP_OBSERVER_HPP
#define UDP_OBSERVER_HPP

#include <string>
#include <chrono>
#include <iomanip>
#include <sstream>

#include "WsfScenarioExtension.hpp"
#include "UtCallbackHolder.hpp"
#include "WsfSimulationExtension.hpp"
#include "WsfExchange.hpp"
#include "json/json.h"

#pragma once
#include <string>
#include <chrono>
#include <iomanip>
#include <sstream>

#include "WsfScenarioExtension.hpp"
#include "ObserverSituationInterface.hpp"
#include "ObserverEventInterface.hpp"
#include "ObserverControlInterface.hpp"
#include "UtCallbackHolder.hpp"
#include "json/json.h"

class GenUDP_Connection;

class UDP_ObserverPrivate
{
public:
	UDP_ObserverPrivate(UtCallbackHolder& callBackes, GenUDP_Connection* conn);
	UDP_ObserverPrivate& operator=(const UDP_ObserverPrivate& aSrc);
	~UDP_ObserverPrivate();

	ObserverControlInterface* mControlInterface = nullptr;
	ObserverEventInterface* mEventInterface = nullptr;
	ObserverSituationInterface* mSituationInterface = nullptr;
};

class  GenUDP_Connection;
class  UtInput;
struct UtPluginObjectParameters;
class  WsfPlatform;
class UDP_ObserverPrivate;

class UDP_Observer : public WsfSimulationExtension
{
   public:
        //! Constructor
        UDP_Observer();
        UDP_Observer(const UDP_Observer& aSrc);
        UDP_Observer& operator=(const UDP_Observer& aSrc);
        ~UDP_Observer() noexcept override;
        bool Initialize() override;
        bool ProcessInput(UtInput& aInput);
        void SendPacket(const std::string &aMessage);
    private:
		struct PlatformSideInfo
		{
			int index;
			std::string side;
			PlatformSideInfo(int idx, const std::string& s) : index(idx), side(s) {}
		};
    public:

    private:
        int                  mPort; //发送到目标端口
        int                  mRecvPort;//接收数据的本地地址
        std::string          mAddress;//发送数据到目标IP地址
        std::vector<PlatformSideInfo> mPlatformSides = {};  // 存储所有平台信息

        UtCallbackHolder     mCallbacks;
        GenUDP_Connection*   mConnectionPtr;
		void Disconnect();
        void initPlatformSides();
        UDP_ObserverPrivate*  mData; //方法数据集合

};

#endif
